#! /usr/bin/ruby
def check_usage
unless ARGV.length == 2
	puts "Usage: ruby my-diff.rb oldfile newfile"
	exit
end
end

def boring? (line, boring_word_list)
        boring_word_list.any?{|boring_word| line.split('/').include?(boring_word)}
end

def trans_to_downcase(filename, boring_word_list)
	downcased = File.open(filename).collect {|line| line.chomp.downcase}
	downcased.reject {|line| boring?(line, boring_word_list) }	
end

def compare_array(old_inventory, new_inventory)
old_array= trans_to_downcase(old_inventory, ['temp','recycler'])
new_array= trans_to_downcase(new_inventory, ['temp','recycler'])

puts "new added files are as below:"

puts ""

puts new_array - old_array

puts "============================="

puts "removed files are as below:"

puts ""

puts old_array - new_array
end

puts "$0 is #{$0}."
puts "__FILE__ is #{__FILE__}." 
if $0 == __FILE__
	check_usage
	compare_array(ARGV[0],ARGV[1])
end
